import { createStore } from 'vuex'

export default createStore({
  state: {
    user: null,
    devices: []
  },
  mutations: {
    SET_USER(state, user) {
      state.user = user
    },
    SET_DEVICES(state, devices) {
      state.devices = devices
    }
  },
  actions: {
    login({ commit }, user) {
      commit('SET_USER', user)
    },
    setDevices({ commit }, devices) {
      commit('SET_DEVICES', devices)
    }
  }
})